<?php
/**
 * 
 * swxCI. 
 * 
 * An effort to bring together the excellent CodeIgniter & SWX.
 * 
 * The swxCI code is based on the CodeIgniter front controller code, 
 * the SWX gateway code. 
 * 
 * CodeIgniter is Copyright (c) 2008, EllisLab, Inc.
 * See codeigniter_license.txt for full license.
 *
 * SWX is licensed under MIT License & Creative Commons GNU GPL License.
 * See http://www.swxformat.org/license.php for further info.
 * 
 * swxCI is released as is, under Creative Commons Attribution 3.0 Unported License
 * Feel free to modify & adapt but respect the existing licenses for its parts.
 * 
 * swxCI is developed by the SWX Format Development team: 
 * http://code.google.com/p/swx-format/
 */

/*
 * ------------------------------------------------------
 *  swxCI utility library
 * ------------------------------------------------------
 */

function _exception_handlerCI($severity, $message, $filepath, $line)
{
	if ($severity == E_STRICT)
	{
		return;
	}

	$error =& load_class('Exceptions');

	if (($severity & error_reporting()) == $severity)
	{
		show_errorCI("~PHP Error ~\nSeverity: $severity, \nMessage: $message, \nFilepath: $filepath, \nLine: $line",1000);
	}
	
	// Should we log the error?  No?  We're done...
	$config =& get_config();
	if ($config['log_threshold'] == 0)
	{
		return;
	}

	$error->log_exception($severity, $message, $filepath, $line);
}

function show_errorCI($message, $code = 999)
{
	if (SWX_DEFAULTFORMAT=='as3')
		$swxAssembler = new SwxAssembler3();
	else
		$swxAssembler = new SwxAssembler();
	$error = array('error' => true, 'code' => $code, 'message' => $message);
	$swxAssembler->writeSwf($error, false,SWX_COMPRESSIONLEVEL);
	exit();
}

function send_result($data)
{
	if (SWX_DEFAULTFORMAT=='as3')
		$swxAssembler = new SwxAssembler3();
	else
		$swxAssembler = new SwxAssembler();
	$swxAssembler->writeSwf($data, false,SWX_COMPRESSIONLEVEL);
}

function getParam($name)
{
	if (isset($_POST[$name]))
		return $_POST[$name];
	elseif (isset($_GET[$name]))
		return $_GET[$name];
	else
		return null;
}


?>